package com.patterns.iterator.prodjectIterator;

import java.util.ArrayList;

/**
 * Created by Xiao Yiyun on 2017/6/28.
 */
public class Project implements IProject {

    //定义一个项目列表，所有的项目都放在这里
    private ArrayList<IProject> projectList = new ArrayList<IProject>();
    //项目名称
    private String name = "";
    //项目成员数量
    private int num = 0;
    //项目费用
    private int cost = 0;

    //构造函数
    public Project() {

    }

    //构造函数
    public Project(String name, int num, int cost) {
        this.name = name;
        this.num = num;
        this.cost = cost;
    }

    //增加项目
    public void add(String name, int num, int cost) {
        this.projectList.add(new Project(name, num, cost));
    }

    //得到项目信息
    public String getProjectInfo() {
        return toString();
    }

    //产生一个遍历对象
    public IProjectIterator iterator() {
        return new ProjectIterator(this.projectList);
    }

    @Override
    public String toString() {
        return "Project{" +
                "projectList=" + projectList +
                ", name='" + name + '\'' +
                ", num=" + num +
                ", cost=" + cost +
                '}';
    }
}
